extends ../_layout

block content
   //- var club = memberships[0].club;
   div.container.bannercontainer
      div.bannerhead
         img(src='/img/club.jpg', width='100%', height='100%')
         
      div.container.bannerbody
         div.panel.panel-primary
            div.panel-body: div.media
               a.pull-left(href='#')
                  img.media-object(src='/img/guild_symbol_1_left.jpg', alt='club icon', width='200', height='200')
               div.media-body
                  h4.media-heading
                     span= club.name
                  table.table
                     tr
                        td= 'Creator'
                        td= club.creator.firstname + ' ' + club.creator.lastname
                     tr
                        td= 'Created on'
                        td= club.createddate
                     tr
                        td= 'Description'
                        td= club.description
                        
            div.panel-heading
               - var joined = false;
               - each m in club.members
                  - if (user && !joined && m._id.toString() == user._id.toString()) joined = true;
               if(!joined)
                  a.btn.btn-info(href='/clubs/join/' + club._id ) Join this club
               if(user && joined)
                  a.btn.btn-info(href='/clubs/leave/' + club._id ) Leave this club
               if(user && user._id.toString() == club.creator._id.toString())
                  a.btn.btn-info(href='/clubs/edit/' + club._id + '/' + user._id) Manage this club
               if(user && user.role && user.role=='admin')
                  a.btn.btn-warning(href='/clubs/delete/' + club._id) Delete
               
               div.pull-right
                  span.badge= club.members.length
                  span= ' members.'
                  
            
                  

         hr

         div.well
            h1= 'Location'
            div#googleMap(style='height:200px;')
   
         div.well
            h1 List of members
            - each m in club.members
               a(href='/users/profile/' + m._id)
                  span.badge= m.firstname + ' ' + m.lastname


   script(src='/js/g-map-api.js')
   script.
      $(document).ready(function(){
         initMap('googleMap');
         drawMarker( #{club.lat}, #{club.lng} );
         centerMap(#{club.lat}, #{club.lng}, 15);
      });

